#ifndef TILE_H_INCLUDED
#define TILE_H_INCLUDED

#include "Common.h"

enum Error_throw {
    LOAD_TILE_FAILED,
};

class TileFile {
public:
    TileFile(const char *filename, ushort w, ushort h);
    ~TileFile();

    BITMAP *getTile(ushort x, ushort y);
    BITMAP *getTile(const Rect &rect);

private:

    BITMAP  *m_TileBase;
    ushort m_w, m_h;
};


class TileManager {
public:
    TileManager();
    ~TileManager();
    void LoadTileDB(const char *dbfile);
    bool LoadFile(const char *filename, ushort w, ushort h, ushort fid);
    BITMAP *getTile(ushort tid);

private:
    map <ushort, BITMAP *> m_tiles;
    TileFile              *m_tileFiles[MAX_TILE_FILES];
};

#endif // TILE_H_INCLUDED
